Design and Fabrication of a Magnetic Actuator for Torque and Force Control Estimated by the ANN/SA Algorithm

Magnetic manipulation has the potential to recast the medical field both from an operational and drug delivery point of view as it can provide wireless controlled navigation over surgical devices and drug containers inside a human body. The presented system in this research implements a unique eight-coil configuration, where each coil is designed based on the characterization of the working space, generated force on a milliscale robot, and Fabry factor. A cylindrical iron-core coil with inner and outer diameters and length of 20.5, 66, and 124 mm is the optimized coil. Traditionally, FEM results are adopted from simulation and implemented into the motion logic; however, simulated values are associated with errors; 17% in this study. Instead of regularizing FEM results, for the first time, artificial intelligence has been used to approximate the actual values for manipulation purposes. Regression models for Artificial Neural Network (ANN) and a hybrid method called Artificial Neural Network with Simulated Annealing (ANN/SA) have been created. ANN/SA has shown outstanding performance with an average R2, and a root mean square error of 0.9871 and 0.0153, respectively. Implementation of the regression model into the manipulation logic has provided a motion with 13 μm of accuracy.


Introduction
Electromagnetism principles and magnetic actuators have been implemented in various applications such as metal forming, where a solenoid with 15 turns generates a magnetic force to push a light metal in order to form a cellphone case [1], real-time production of magnetic materials with the 3D printer in additive manufacturing is feasible by aligning the particles with the magnetic field [2]. In addition, magnetic levitation can be used to design a stable suspension for metal additive manufacturing, which results in substrate elimination [3]. For biological purposes, the electroless plating technique has been used to make magnetic microparts that can rotate at high speed using a magnetic actuator for functional lab-on-a-chip devices [4]. Microfluidics has also utilized magnetically actuated discs to control the flow, mixing, reaction, and separation of fluid [5]. Furthermore, the conversion of kinetic energy of human movement into electrical power is possible using a coil-spring system [6]. The density of dense non-magnetic materials, such as glass, is also measurable, by analyzing the strength of the levitation of a single iron-core coil (electromagnet) [7]. In another study, the variation of the eddy current produced by a coil is measured to detect the place and size of different defects [8]. In addition to the eddy current, electromagnetic impedance and magnetic field values in one direction are also utilized to develop various detection sensors, where one can detect a different contaminant in hydraulic oil [9] and measure the size and position of a contaminant during the casting process [10], respectively.
Magnetic actuators are also implemented in micro-electro-mechanical systems (MEMSs) such as micropumps [11], stable grasping [12], pick-and-place system [13], small force sensing [14], contactless delivery [15], and microsurgery [16]. Microsurgery can provide a minimally invasive surgery environment and offer benefits such as lower infection risk, fewer medical complications, and faster rehabilitation [17,18]. Bioengineering combined with the small-scale (millimeter and sub-millimeter) wireless robots manipulated via the magnetic field can potentially modernize the medical field [19] by replacing the current devices with safer alternatives that enable surgeons to access fragile organs such as the eye, heart, and brain to perform more precise and less invasive operations. It can also be utilized to navigate capsules inside the body for targeted delivery purposes and approach part of the body that was not safely accessible before [20].
Octomag is a magnetic actuator developed to enhance retinal surgery by eliminating irreversible damage to the eye through the control constraints that could even respond appropriately to unpredicted issues such as patient movement. This device contains eight electromagnets to perform a 5 degree of freedom (5 DOF), transition, and orientation, via magnetic force and torque control [21]. Octomag utilizes a linear relationship of fields generated by an individual coil to calculate the total magnetic field using the FEM approach. Then, calculated magnetic field values are calibrated with a few known values measured from the actual coil in order to form the control logic.
Yuan et al. have designed an eight metal-core coil actuator that adopted the same concept as the Octomag to navigate a capsule inside the stomach [22]. Minimag was also motivated by OctoMag, enabling 5 DOF inside a spherical working space surrounded by eight iron-core coils. This system also followed the same approach of calibrating the FEM simulations to develop its control logic [23].
Catheter positioning [24,25] is another main advantage of magnetic manipulators; the catheter guidance control and imaging (CGCI) systems use eight giant coils and have been implemented at an industrial size [26]. Moreover, Bigmag has used six moving coils to navigate a catheter [27]. Figure 1 indicates the developed system utilized in this study to manipulate a disk magnet with a diameter and thickness of 0.1 and 0.0625 inches, respectively. The manipulator contains eight coils in an open-asymmetric configuration that enables wider access to the working space than the mentioned systems and does not compromise torque-force controllability within the workspace [28]. This configuration also follows the square antiprism of Thomson's method [29] and can be modeled using the superposition theorem. This project assumes that the changes in a magnetic field are infinitely small; hence, Maxwell laws are applicable. Moreover, due to the high magnetic permeability of the pure iron core, the inserted core discharges almost instantly after getting magnetized; therefore, the slight non-linearity can be neglected, meaning that the superposition is still valid.

Coil Design
As indicated in Figure 2, the radius of the spherical working space is correlated to the outer diameter of the coils. The surface area of coils is represented with planes, where the largest coil diameter is located at the intersection of the planes. The relationship between the largest outer radius of the coils, R out , and spherical working space, R sphere , in the open-asymmetric configuration, can be modeled as: By equating the spherical radius to 60 mm, the outer diameter of the coil should be less than 69.2820 mm. The selection of the outer diameter leads to using the Fabry factor, G, to measure the coils' inner radius and height.
where R in and l are the inner radius and length of the coil, respectively. The optimum values for these factors are shown in Figure 3.
G factor parameterizes the coil's dimension, generating the least heat dissipation to produce a magnetic field. In this study, the G factor has been combined with the force generated on a 1-mm 3 magnet located at the center of the working space. Therefore, the coil's parameters that generate the most force value with minimum power consumption will be selected as the final coil.

Magnetic Force and Torque
The generated magnetic force and torque of a coil can be calculated using Maxwell Law: where J, B, and µ 0 are the current density, magnetic field, and magnetic permeability of the free space. The force (F) and torque (τ) acting on an object with the dipole moment of m is equal to: Equations (5) and (6) can be represented in matrix form [30]: and (7) and (8) can be integrated to form wrench, W: where O is the zero matrix with right dimensions, g is the gradient, and S is in skew functions. By applying superposition theorem to (9) the contribution of each coil carrying current I at point p in the working space can be calculated as: where A is called the actuation matrix then the amount of current flowing through each coil is: where † is the pseudo inverse.

Deep Learning
As previously mentioned, FEM is used to predict the magnetic field at each point for experimental purposes. However, FEM models cannot capture the manufacturing error caused during the coil winding process. Coil winding is a delicate process and is consistently associated with unwanted gaps, reducing the number of designed turns in the actual coil. In addition, pure iron becomes deformed easily during core manufacturing and changes its dimensions after the annealing process; therefore, even a perfect model cannot represent the actual coil properties and model magnetic field values. In addition to the mentioned barriers, FEM itself is associated with an approximation error that is a part of this approach. Figure 4 indicates the insensibility of the design to permeability change of the iron core. Moreover, Figure 5 illustrates the difference between actual and calculated values of the magnetic field on the axial axis of a coil, with an average error of 17%. In order to enhance the modeling of the magnetic field and consider human error, deep learning has been used as an alternative to approximate the magnetic field values. Deep learning eliminates the need for collecting too many data points and can be developed with few values inside the region of the interest. Artificial Neural Network (ANN) and a hybrid model, Artificial Neural Network with Simulated Annealing (ANN/SA) algorithm, have been implemented in this study.

ANN
The artificial neural network is a deep learning approach, a subfield of machine learning, where the structure of the human brain inspires the foundation of the algorithm [31]. The ANN algorithm uses training data to recognize the patterns and predict the outputs for a new set of similar data [32]. The training data is fed to the network as an input layer; then, it moves along channels through hidden layers, which are the core processing units of the network, to the output layer. Figure 6 indicates the general structure of a network. Each channel is assigned to a number known as weight, which scales the neuron from the previous layer and feeds it to the neuron in the next layer. All the channels toward a particular neuron will be added together; then, another value known as the bias or interception point is added to this equation. Finally, an activation function will be applied to the neuron before it leaves toward the next layer through its channels. The weight adjustment process will be done through backpropagation, mainly using the gradient descent approach [33]. For most regression problems, the outer layer is only a summation of the last layer's neuron values multiplied by their associated weights plus the interception point without any activation matrix. Figure 7 illustrates the scaling, bias (b), and activation function ( f ) over one neuron only; this process is known as forward propagation [34]. The weight associated with the channel that connects the jth neuron of the layer l to the ith element of the next layer will be shown as ω (l) ji ; the first number in the subscript is the neuron that the channel leaves from, and the second one is where it lands; the superscript also refers to the layer that the channel roots from, for example, the ω (3) 52 , which connects the fifth neuron of the third layer to the second neuron of the fourth layer.
where n and k are the number of neurons at the l + 1 and the l layers, respectively. The weight matrix can also be shown as ω l .

ANN/SA
The ANN algorithm's performance and convergence are heavily dependent on the initial weight values; therefore, it is beneficial to develop a method that can produce initial weights and biases that increase the probability of reaching the global minimum and increase the learning pace of the network.
ANN/SA optimizes the randomly generated initial weights and biases values; once the best initial values are selected, the network training process starts. The thermomechanical annealing process inspired the optimization of random values [35]. The metal is heated to a higher temperature and cooled down, resulting in a variation in the metal's atomic structure and material properties. The atomic structure and the temperature of the metal will be related together, and if the temperature drops slowly, it can be related to the energy change of the metal [36]. Figure 8 illustrates the explained process.
This method was used to optimize nonlinear functions involving multiple local minimums, and it uses the Metropolis algorithm to simulate the annealing process [37]. Since it is not a greedy process, the probability of reaching a local minimum is considerably low. During the training process, the SA will adjust the weights randomly, considering the algorithm's temperature change and evaluating the network's accuracy; once the accuracy has been calculated, the Metropolis algorithm decides whether the created solution is acceptable-the probability of acceptance P a is: where ∆E is the error between the new solution and current solution, y is the current temperature, and k is the acceptance constant, based on the range of weights, biases, and inputs. As (13) indicates, the algorithm will frequently be accepting new results at high temperatures, however becomes more selective at the lower ones. The cooling schedule can be exponential, linear, and temperature cycling. In order to calculate the temperature at each state using the temperature cycling method, the following equations should be implemented [38]. This method first takes a series of n ∈ [1, N] scenarios for temperature: where the total number of temperatures is N, the starting temperature is x [1], the final temperature is x[N], and cooling constant is ρ presented by: x [1] ) .
If the number of cycles before each optimization is expressed as M and the temperature assigned to the simulated annealing indicated by y[n], the schedule of the cooling process can be modeled as: ultimately, the weight preparation of the layer l for the temperature can be formulated as: where u is a random variable that is uniformly distributed and takes values between [0, 1), γ is a value equal to 20 or 30, and λ is the perturbation ratio:

Validation
In order to evaluate the performance of each developed algorithm and select the best approximation, Root-Mean-Square-Error (RMSE) and R-Squared (R 2 ) are utilized.
where y i ,ŷ i ,ȳ i , and N are the actual, predicted, mean of actual set values, and the number of samples, respectively. Once each model had been optimized, the final algorithm will be additionally evaluated using the values mentioned in Table 1 to check its predictability [39,40].

Variable Equation Criteria
Mean Absolute Error (MAE)

As low as possible Mean Absolute Percentage Error (MAPE)
Squared correlation of actual vs predicted (Ro 2 ) (

Designed Coil
The coil is wound using an AWG 14 wire with a diameter of 1.73228 mm with its isolation. The α value for the various number of vertical layers has been investigated considering the diameter of the wire and the geometric restriction of 67.69 mm of the coil's outer diameter. As indicated in Figure 9a, the optimum value of α = 3.3019 occurs at 14 layers. Moreover, as Figure 9b illustrates, the calculation for optimum feasible alpha value starts when inner and outer radiuses are equal, meaning that the thickness is zero, then it continues by adding one layer at each step and calculates the alpha value accordingly. Figure 9 indicates that the optimum α value is associated with a 10.25-mm inner radius.
The coil's inner radius selection leads to β optimization. As indicated in Table 2, by varying the length of the coil and modeling each scenario on Ansys Maxwell 2020 the magnetic force had been calculated. According to the Figure 10, which is the illustration of the normalized force and Fabry factor indicated in Table 2, a length of 124 mm indicates a coil that provides almost as much force with less power consumption than the next scenario. Therefore, the optimum coil is a cylindrical iron-core coil with 3.3019, 6.0761, and 0.140 for α, β, and G values, respectively.

Data Collection
As indicated in Figure 11, the magnetic field had been measured using a Gauss meter over a 7 × 7 × 6 grid, where y, z ∈ [−10 mm, 10 mm] and x ∈ [52 mm, 72 mm]. A total of 294 points for a coil running at one amp were collected for each magnetic field component. The input data is the location of the point of interest above the coil, and the target or label is the magnetic field components, B x , B y , and B z . In order to guarantee the convergence of the algorithms and reach the global minimum, the collected data have been normalized using the upper-lower approach between 0.05 and 0.95; Figure 12 shows the effect of normalization on targets.

Algorithm Development
Each target has its own algorithm developed separately for each method. However, to ensure that the algorithms receive the same samples, the data set associated with targets had been randomly shuffled and split into three categories: train, test, and validation sets. The train set consists 70 percent of the initial data, with 206 samples, whereas the test and validation sets are filled with only 15 percent, with 44 samples each. Each model is developed using the train set, where its hyperparameters are tuned using the test set.
Finally, the algorithm's performance is measured on validation as unseen data to ensure the accuracy of the model.

ANN
The network has been developed using one hidden layer consisting of four to seven neurons. The Adam optimizer, stochastic gradient descent method, a learning rate of 0.001, and batch size of 64 was chosen. The hidden layer is formed by activating a relu function, and the output layer is the linear combination of the neurons and biases times to associated weights of the hidden layer. Figure 13 indicates the number of neuron selection process based on R 2 and RMSE for each target. The highest R 2 and lowest RMSE are associated with seven, four, and six neurons for B x , B y , and B z , respectively. Figure 14 shows the implementation of the developed algorithm on the train, test, and validation sets. B z reached R 2 > 0.950 on all the sets; whereas, B x and B y reached as far as R 2 = 0.889 and R 2 = 0.876.

ANN/SA
The network was created using similar data and structure as ANN. By using temperature cycling for the cooling cycle with initial and final temperatures of 15 and 0.015, the data set associated with each magnetic field component was trained and tested in NeuralLab v.3.1 software. Models indicated that the Levenberg-Marquardt algorithm had worked better in all cases than the gradient descent. According to Figure 15, B x and B y components have performed better with seven neurons than other scenarios. Moreover, Figure 15 indicates that among four scenarios, a structure with seven neurons B z is the optimal structure on the training data; however, six neurons are better than others on the test set. Since performance on the test set is more important than training and the six-neuron structure is the second best on the training set, the optimum structure will be six neurons.  Figure 16 illustrates the scatter plots with associated R 2 and error values for optimal structures. The performance of this approach shows a significant improvement compared to the ANN approach. The scatter plots closely follow the red line and has a minimal residual. However, the test performance of the Bx component is very similar to the ANN performance.

Extra Validation
According to Figures 14 and 16, the ANN/SA is a better approach to approximate the magnetic field than the other one. Therefore, the predictability of this algorithm on the validation set has been checked as the final performance measurement. As Table 3 indicates, all the variables are in the expected range, and the regression models can be used for manipulation purposes. Figure 17 indicates the field values over the 7 × 7 × 6 grid, where y, z ∈ [−10 mm, 10 mm] and x ∈ [52 mm, 72 mm]. As can be seen, the actual values and approximated values are close to each other and the mean error percentage is 0.0633%.

Motion
The developed algorithm has indicated reliable results and can be utilized for manipulation purposes. Each designed coil also can produce a maximum of 83.43 mH magnetic field at a maximum current of 10 amp, which is enough to manipulate at a milli/micro scale. Figure 18 is a representation of a magnet attached to a flexible road acting as the robot. This disk magnet has a dipole moment of 0.0084 Am 2 with a diameter and thickness of 0.1 and 0.0625 inches. The agent will be navigated only in one direction toward a laser sensor which provides real-time position feedback of the agent. Since there is no other information, such as the agent's orientation, provided by the laser sensor, the system can become unstable quickly. To overcome the rotational instabilities, the attached flexible part to the agent was designed to be heavier than its normal weight. Figure 19 indicates the fabricated system utilized to run the experiment.  The provided position by the laser sensor will be used to calculate the amount of required current at each coil utilizing (11). The actuation logic, indicated in Figure 20, has resulted in the movement of the robot with an acceleration rate of 0.228 mm/s 2 toward a 0.5-mm point resulting in a movement accuracy of 13 µm. In this logic, the current state of the robot is collected from the laser sensor and compared to the desired point. The motion continues until the difference between the desired and current points is considerably small, meaning that the associated wrench cannot overcome the friction force. Figure 21 illustrates the movement of the robot with respect to time.

Conclusions
This work demonstrated a magnetic manipulator's design and implementation process with eight coils. The integration of the Fabry factor and force strength has led to an optimal coil with an inner radius, outer radius, and height of 20.5, 67.69, and 124.56 mm, respectively. Due to the error associated with FEM, 17% in this study, the magnetic field produced by this coil at one amp has been collected over a 7 × 7 × 6 grid and approximated using deep learning techniques, ANN and ANN/SA. Although both models showed an acceptable performance, the ANN/SA showed more reliable performance values with an average of RSME = 0.0153 and R 2 = 0.9871, 76.61% less and 9.66% more than the ANN model, respectively. Utterly, the developed algorithm was used to approximate the magnetic field and navigate an agent from almost the center of the working space toward a half-millimeter away from it along a laser sensor direction. The manipulation had been implemented successfully with 13 µm of accuracy.

Informed Consent Statement: Not applicable.
Data Availability Statement: You can request data using the Maglev Laboratory at University of Waterloo.

Conflicts of Interest:
The authors declare no conflict of interest.

Abbreviations
The following abbreviations are used in this manuscript: